<!DOCTYPE html>
<html lang="zh">
<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>验证</title>
	<script src="https://cdn.dingxiang-inc.com/ctu-group/captcha-ui/index.js"></script>
	<style>
		#dx {
			margin: 50px auto;
		}
	</style>
</head>
<body>
	<div id="dx"></div>
</body>
</html>
<script type="text/javascript" src="https://js.cdn.aliyun.dcloud.net.cn/dev/uni-app/uni.webview.1.5.2.js"></script>
<script>
	document.addEventListener('UniAppJSBridgeReady', () => {
		uni.postMessage({
			data: {
				action: 'message'
			}
		});
		let typeIndex = document.location.search.indexOf("paytype")
		let idIndex = document.location.search.indexOf("?")
		let result = document.location.search
		let id = result.slice(idIndex+4,typeIndex-1)
		let paytype = result.slice(typeIndex+8,result.length)
		var myCaptcha = _dx.Captcha(document.getElementById('dx'), {
			appId: '36fdcf220f434585762dc992c0a50dfc', 
			apiServer: 'https://cap.dingxiang-inc.com',
			success: function(token) {
				// console.log('token:', token)
				
				uni.redirectTo({
					url: '/pages/Order/pay?token='+token + '&id=' +id+'&paytype='+paytype, //此处跳转带上token +'&paytype='+paytype
				});
			},
			fail: function (e) {
				console.log(e);
			}
		})
		myCaptcha.on('verifySuccess', function (security_code) {
		  myCaptcha.reload()
		})
		
		// myCaptcha.on('ready', function () {
		//   console.log('captcha is ready!')
		// })
		
	})
	
</script>